package com.hmy.infrastructure.common.config;

import com.fasc.open.api.v5_1.client.*;
import com.hmy.infrastructure.common.properties.FadadaProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

import javax.annotation.Resource;

/**
 * @Description
 * @Author seven.qi
 * @Date 2023/11/27 15:46
 * @Version 1.0
 */
@Configuration
@Order(100)
public class FadadaClientConfig {
    @Resource
    private FadadaProperties fadadaProperties;

    @Bean
    public OpenApiClient openApiClient() {
        return new OpenApiClient(fadadaProperties.getAppId(), fadadaProperties.getAppSecret(), fadadaProperties.getServerUrl());
    }

    /**
     * 服务访问凭证
     */
    @Bean
    public ServiceClient serviceClient() {
        return new ServiceClient(openApiClient());
    }

    /**
     * 文件管理
     */
    @Bean
    public DocClient docClient() {
        return new DocClient(openApiClient());
    }

    /**
     * 个人用户管理
     */
    @Bean
    public UserClient userClient() {
        return new UserClient(openApiClient());
    }

    /**
     * 企业用户账号管理
     */
    @Bean
    public CorpClient corpClient() {
        return new CorpClient(openApiClient());
    }

    /**
     * 组织管理
     */
    @Bean
    public OrgClient orgClient() {
        return new OrgClient(openApiClient());
    }

    /**
     * 印章管理
     */
    @Bean
    public SealClient sealClient() {
        return new SealClient(openApiClient());
    }

    /**
     * 文档模板管理
     */
    @Bean
    public TemplateClient templateClient() {
        return new TemplateClient(openApiClient());
    }

    /**
     * 签署任务管理
     */
    @Bean
    public SignTaskClient signTaskClient() {
        return new SignTaskClient(openApiClient());
    }

    /**
     * EUI页面链接管理
     */
    @Bean
    public EUIClient euiClient() {
        return new EUIClient(openApiClient());
    }
}
